package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.RecordEnclosu;
import com.ruoyi.system.mapper.RecordEnclosuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EmergencyRecordMapper;
import com.ruoyi.system.domain.EmergencyRecord;
import com.ruoyi.system.service.IEmergencyRecordService;

/**
 * 上报记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-06-30
 */
@Service
public class EmergencyRecordServiceImpl implements IEmergencyRecordService 
{
    @Autowired
    private EmergencyRecordMapper emergencyRecordMapper;
    @Autowired
    private RecordEnclosuMapper recordEnclosuMapper;

    /**
     * 查询上报记录
     * 
     * @param erId 上报记录ID
     * @return 上报记录
     */
    @Override
    public EmergencyRecord selectEmergencyRecordById(Long erId)
    {

        EmergencyRecord emergencyRecord = emergencyRecordMapper.selectEmergencyRecordById(erId);
        RecordEnclosu recordEnclosu = new RecordEnclosu();
        recordEnclosu.setErId(erId);
        emergencyRecord.setRecordEnclosu(recordEnclosuMapper.selectRecordEnclosuList(recordEnclosu));
        return emergencyRecord;
    }

    /**
     * 查询上报记录列表
     * 
     * @param emergencyRecord 上报记录
     * @return 上报记录
     */
    @Override
    public List<EmergencyRecord> selectEmergencyRecordList(EmergencyRecord emergencyRecord)
    {
        List<EmergencyRecord> emergencyRecords = emergencyRecordMapper.selectEmergencyRecordList(emergencyRecord);
        RecordEnclosu recordEnclosu =new RecordEnclosu();
        return emergencyRecordMapper.selectEmergencyRecordList(emergencyRecord);
    }

    /**
     * 新增上报记录
     * 
     * @param emergencyRecord 上报记录
     * @return 结果
     */
    @Override
    public int insertEmergencyRecord(EmergencyRecord emergencyRecord)
    {   emergencyRecord.setErCreattime(DateUtils.getNowDate());
        return emergencyRecordMapper.insertEmergencyRecord(emergencyRecord);
    }

    /**
     * 修改上报记录
     * 
     * @param emergencyRecord 上报记录
     * @return 结果
     */
    @Override
    public int updateEmergencyRecord(EmergencyRecord emergencyRecord)
    {emergencyRecord.setUpdateTime(DateUtils.getNowDate());
        return emergencyRecordMapper.updateEmergencyRecord(emergencyRecord);
    }

    /**
     * 批量删除上报记录
     * 
     * @param erIds 需要删除的上报记录ID
     * @return 结果
     */
    @Override
    public int deleteEmergencyRecordByIds(Long[] erIds)
    {
        return emergencyRecordMapper.deleteEmergencyRecordByIds(erIds);
    }

    /**
     * 删除上报记录信息
     * 
     * @param erId 上报记录ID
     * @return 结果
     */
    @Override
    public int deleteEmergencyRecordById(Long erId)
    {
        return emergencyRecordMapper.deleteEmergencyRecordById(erId);
    }

}
